package xyf.p04.tree;

import commons.TreeNode;

/**
 * ClassName: P0101_Miorr
 * Description:
 * Author: xyf
 * Date: 9/7/22 10:18 PM
 * Version: 1.0
 **/
public class P0101_Miorr
{
    public boolean isSymmetric(TreeNode root)
    {
        return check(root, root);
    }

    private boolean check(TreeNode p, TreeNode q)
    {
        if (p == null && q == null)
        {
            return true;
        }
        if (p == null || q == null)
        {
            return false;
        }
        return p.val == q.val && check(p.left, q.right) && check(p.right, q.left);
    }
}
